/*
 * @Author: 黄宇/Hyuishine
 * @Date: 2021-12-06 09:43:19
 * @LastEditors: 胡俊/treence
 * @LastEditTime: 2022-06-06 16:09:57
 * @Description:
 * @Email: hyuishine@gmail.com
 * @Company: 3xData
 * @youWant: add you want
 */
import globalPostRequest from "@/request/globalPostRequest.js";

// 登录接口
export function login_login(data, callback) {
  return globalPostRequest({
    url: "/login",
    method: "post",
    data,
    header: {
      "content-type": "application/json;charset=UTF-8",
    },
    callback,
  });
}

// 获取验证码
export function getCodeImg(callback) {
  return globalPostRequest({
    url: "/captchaImage",
    method: "get",
    timeout: 20000,
    callback,
  });
}

// 获取用户信息
export function get_userInfo(callback, token) {
  return globalPostRequest({
    url: "/system/user/getInfo",
    method: "get",
    header: {
      Authorization: token,
    },
    callback,
  });
}

// 退出登录
export function logOut(callback) {
  return globalPostRequest({
    url: "/logout",
    method: "POST",
    callback,
  });
}

// 服务机构注册
export function addOrganization(data, callback) {
  return globalPostRequest({
    url: "/agencyInfo",
    method: "POST",
    data: data,
    header: {
      "content-type": "application/json;charset=UTF-8",
    },
    callback,
  });
}

// 服务机构注册时判断统一信用代码和单位名称
export function creditCode(data, callback) {
  return globalPostRequest({
    url: "/agencyInfo/checkInfo",
    method: "POST",
    data: data,
    header: {
      "content-type": "application/json;charset=UTF-8",
    },
    callback,
  });
}

// 社会单位注册
export function addUnitInfo(data, callback) {
  return globalPostRequest({
    url: "/unitInfo",
    method: "POST",
    data: data,
    header: {
      "content-type": "application/json;charset=UTF-8",
    },
    callback,
  });
}

// 所属区域树
export function getTree(data, callback) {
  return globalPostRequest({
    url: "/modules/area/getTree",
    method: "get",
    header: {
      "content-type": "application/json;charset=UTF-8",
    },
    callback,
  });
}

// 赣企通获取用户信息
export function getUserTicketApi(data, callback) {
  return globalPostRequest({
    url: "/authLogin?ticket=" + data.ticket,
    method: "post",
    data,
    header: {
      "content-type": "application/json;charset=UTF-8",
    },
    callback,
  });
}
